<?php

error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
session_start();
define('PATH_ROOT', realpath(dirname(__FILE__) . '/../'));
define('PATH_SQLITE', PATH_ROOT . '/sqlite/');
define('PATH_CONTROLLER', PATH_ROOT . '/php/controllers/');
define('PATH_LIB', PATH_ROOT  . '/php/lib/');


$action = (isset($_GET['action']) ? $_GET['action'] : 'index') . 'Action';
$controllerName = ucfirst(isset($_GET['controller']) ? $_GET['controller'] : 'home') . 'Controller';
$controllerPath = PATH_CONTROLLER . $controllerName . '.class.php';
if (!file_exists($controllerPath)){
	echo '404';
}

include PATH_LIB . 'Controller.class.php';
include PATH_CONTROLLER . 'CommonController.class.php';

include $controllerPath;
$controllerHandle = new $controllerName();
if(method_exists($controllerHandle, $action)){
	call_user_func_array(array($controllerHandle, $action), array());
}
?>